package netty_5_demo;

import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;

public class SubReqServerHandler extends ChannelHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
//        super.channelRead(ctx, msg);
        UserEntity userEntity = (UserEntity)msg;
        System.out.println("id：" + userEntity.getId() + "，name: " + userEntity.getUserName());
        ctx.writeAndFlush(getUser(userEntity.getId()));
    }


    private UserEntity getUser(Integer id){
        UserEntity userEntity = new UserEntity();
        userEntity.setId(id);
        userEntity.setUserName("libofei");
        return userEntity;
    }
}
